$(function(){
    GetList();
    $('.btn-edit').click(function(){
        let id = $(this).attr('ids');
        layOpen('修改','600px','600px','modelEdit.html?id='+id);
    });

    $('.btn-del').click(function(){
        let id = $(this).attr('ids');
        layFirm('删除','admin/ModelDel',{id:id});
    });

    $('#search').click(function(){
        GetList();
    })
});
function GetList(){
    let page = GetQueryString('page');
    let content = $('input[name="content"]').val();
    let type = $('select[name="type"]').val();
    let datas = {page:page,content:content,type:type};
    let data = AjaxForm('admin/MsgModel','get',datas);
    let html = ``;
    for (let i=0;i<data.list.length;i++){
        let  del = `<a class="layui-btn layui-btn-danger btn-red btn-del" ids="${data.list[i].id}">删除</a>`;
        html += `<tr class="table-content" style='height: 50px;'>
                    <td style="width: 10%">${data.list[i].title}</td>
                    <td style="width: 55%">${data.list[i].content}</td>
                    <td style="width: 15%">${data.list[i].desc}</td>
                    <td style="width: 15%">
                       <a class="layui-btn btn-add btn-default btn-edit" ids="${data.list[i].id}">编辑</a>
                    </td>
                `;
    }
    $('#data-table').html(html);
    WepPage(data.count,page,'model');
    $('input[name="content"]').val(content);
    $('option[value="'+type+'"]').attr('selected','selected');

}